package com.example.myapplication.ui.activity.collect

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.myapplication.request.CollectRequest
import kotlinx.coroutines.launch

/**
 *新增收藏的viewModel
 *
 * @author : Kun
 * @date : 2021/6/8
 * @time : 17:07
 */
class AddCollectionViewModel : ViewModel() {
    /**
     * 收藏相关的请求
     */
    val collectRequest = CollectRequest()

    /**
     * 新增站外文章
     */
    fun requestAddOtherArticle(title: String, author: String, link: String) {
        viewModelScope.launch {
            collectRequest.requestAddOtherArticle(title, author, link)
        }
    }

    /**
     * 收藏网站
     */
    fun requestAddWebsite(name: String,  link: String) {
        viewModelScope.launch {
            collectRequest.requestAddWebsite(name,  link)
        }
    }

    /**
     * 编辑收藏网站
     */
    fun requestEditWebsite(id:Int,name: String,  link: String) {
        viewModelScope.launch {
            collectRequest.requestEditWebsite(id,name,  link)
        }
    }
}